home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / asmlib40.zip / GRAPHICS.DOC < prev    next >
Text File  |  1995-04-01  |  74KB  |  2,138 lines

  1.  
  2. ****************************** GRAPHICS *************************************
  3.  
  4. ASMLIB Graphics (C) Copyright 1991 - 1995 Douglas Herr
  5. All rights reserved
  6.  
  7. ASMLIB recognizes and automatically supports several graphics modes,
  8. including several which are not recognized by IBM's BIOS.  All ASMLIB
  9. graphics subroutines write directly to the video hardware.
  10. IMPORTANT: ALL ASMLIB GRAPHICS SUBROUTINES ASSUME DS:@DATA.
  11.  
  12. Locations on Graphics screens are defined by coordinate pairs such as (x,y).
  13. X-coordinates are the horizontal dimensions of the screen, and Y-coordinates
  14. are the vertical coordinates.  X = 0 is the at the left edge of the screen,
  15. and X = 719 is the right edge of a Hercules screen, while Y = 0 is the top
  16. edge of the screen and Y = 347 is the bottom (Hercules).  Thus, the
  17. coordinate specified by (719,0) is the extreme upper right corner of a
  18. Hercules screen.
  19.  
  20. BitBlock subroutines in ASM86H.LIB and ASM286H.LIB work with huge data
  21. blocks (larger than 64k).  This permits entire EGA, VGA or InColor screens
  22. to be saved in one block if sufficient RAM is available.
  23.  
  24.  
  25.  
  26. Graphics subroutines as powerful and flexible as ASMLIB's can be quite
  27. large.  If you have licenced ASMLIB source code, you can use several
  28. pre-defined conditional assembly directives to eliminate code from
  29. ASMLIB object files if you do not want or need to support all graphics
  30. modes:
  31.  
  32.         NOHERC      eliminates all Hercules and InColor code
  33.         NOINCOLOR   eliminates code for the InColor card
  34.                (InColor works with Hercules monochrome code in 2 colors)
  35.         NO256       eliminates code for the three 256-color modes
  36.         NOCGA       eliminates code for CGA graphics modes
  37.         NOMCGA      elimiates code for MCGA mode 11h
  38.         NOLPATTERN  elimiates code for non-solid lines (in DRAWLINE.ASM)
  39.  
  40. for example, if you want line drawing programs to use only EGA/VGA-type
  41. 16-color modes, assemble DRAWLINE.ASM like this:
  42.  
  43.          C:\MASM\>masm /dnoherc /dnocga /dno256 /dnomcga drawline;
  44.  
  45. this reduces the size of drawline.obj significantly and speeds its
  46. operation somewhat.
  47.  
  48. If you want to support only 16-color EGA/VGA-type modes, you may also use
  49. the EVGA*.LIB libraries to eliminate much of the code and data required
  50. for monochrome, InColor, CGA and 256-color modes.  The EVGA*.LIB libraries
  51. can eliminate several thousand bytes from your executable files.
  52.  
  53. Example:
  54.  
  55. LINK /NOE mycode.obj,,,EVGA86M+ASM86M;
  56.  
  57. When using the EVGA* libraries, the EVGA* library must appear before
  58. the main library on the command line so that LINK uses the subroutines in
  59. the EVGA library instead of the general ASMLIB subroutines.  You must also
  60. use LINK's /NOE switch.
  61.  
  62. The EVGA* libraries are provided with standard ASMLIB registration:
  63.  
  64. EVGA86T.LIB      for all PCs, tiny model
  65. EVGA86S.LIB      for all PCs, small model
  66. EVGA86M.LIB      for all PCs, medium model
  67. EVGA86H.LIB      for all PCs, huge model
  68. EVGA286T.LIB     for 286 or better PCs, tiny model
  69. EVGA286S.LIB     for 286 or better PCs, small model
  70. EVGA286M.LIB     for 286 or better PCs, medium model
  71. EVGA286H.LIB     for 286 or better PCs, huge model
  72.  
  73.  
  74. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  75.  
  76. Graphics modes and pages supported are:
  77.  
  78. Mode           Maximum x   Maximum y   Colors  Pages (1)  Equipment
  79.                 ("xmax")    ("ymax")
  80.  
  81. HGraph           719          347       2         0, 1    HGC, HGC+ (2)
  82. HGraph           719          347      16         0, 1    InColor  (2)
  83. 04h, 05h         319          199       4         0       CGA, EGA, MCGA, VGA
  84. 06h              639          199       2         0       CGA, EGA, MCGA, VGA
  85. 0Dh              319          199       16        0 - 7   EGA, VGA  (3)
  86. 0Eh              639          199       16        0 - 3   EGA, VGA  (3)
  87. 0Fh              639          349       4         0       EGA, VGA  (4)
  88. 10h              639          349       16        0, 1    EGA, VGA  (3,5)
  89. 11h              639          479       2         0       MCGA, VGA
  90. 12h              639          479       16        0       VGA
  91. 13h              319          199       256       0       MCGA, VGA
  92. 40h              639          399       2         0       ATT 6300
  93. 6Ah              799          599       16        0       VESA  (6)
  94. XMode16      up to 799     up to 599    16        0       Super EGA/VGA
  95. VGA13X      319 or 359    199 to 479    256       (7)     VGA
  96. SVGA16      799 or 1023   599 or 767    16        0       Super VGA (8)
  97. SVGA256     639 to 1023   399 to 767    256       0       Super VGA (8)
  98.  
  99. (1) page numbering begins with page 0.  Several modes have sufficient
  100.     memory available for additional page(s).
  101. (2) page 1 available after calling Use64k
  102. (3) EGA pages assumes 256k EGA memory
  103. (4) monochrome monitor
  104. (5) EGA with 128k or more memory
  105. (6) VESA mode 6Ah is supported by many Super VGA cards with multi-frequency
  106.     monitors
  107. (7) VGA13X pages available range from 0 to 3.  See VGA13X in MODE.DOC.
  108. (8) requires VGAKIT-compatible Super VGA and multi-frequency monitor.  See
  109.     IsSEVGA in SYSTEM.DOC; also see SVGA16 and SVGA256 in MODE.DOC.
  110.  
  111. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  112.  
  113. BEZIER:        draw a Bezier curve on the screen
  114. Source:        bezier.asm (drawline.asm)
  115.  
  116. 80x87 or emulator required
  117.  
  118. Call with:     DS:[BX] pointing to curve coordinate data
  119.                CX = number of points on curve (0 < CX < 32768)
  120.                 a larger number of points on the curve will result in
  121.                 slower operation and a smoother curve.  In many cases
  122.                 CX > 50 will not improve the appearance of the curve.
  123.  
  124.                 Four coordinates are required: two curve endpoints and
  125.                 two control points.  The curve endpoints (x0, y0) and
  126.                 (x3, y3) are similar to DrawLine's coordinates; if you
  127.                 call bezier with CX = 1, you will see only a straight
  128.                 line between the endpoints.  The "control points" act
  129.                 like magnets, pulling the curve away from a straight line.
  130.                 At each endpoint, the curve is tangent to a line drawn
  131.                 between the endpoint and the adjacent control point
  132.                 ("adjacent" control point meaning adjacent in the data
  133.                 structure).
  134.  
  135. Returns:       nothing
  136. Uses:          all 80x87 registers
  137. Supports:      all ASMLIB graphics modes; drawmode 0 not recommended
  138. Example:
  139.  
  140. extrn  bezier:proc
  141.  
  142. .data
  143. extrn  drawmode:byte
  144. bz     dw 50,50            ; first endpoint:       (x0, y0)
  145.        dw 100,0            ; first control point:  (x1, y1)
  146.        dw 200,0            ; second control point: (x2, y2)
  147.        dw 250,175          ; second endpoint:      (x3, y3)
  148.                            ; note that both control points in this
  149.                            ; example pull the curve toward the top of the
  150.                            ; screen
  151.  
  152. .code
  153. ; program fragment assumes DS:@data, 80x87 is installed
  154. ; and that the screen is in graphics mode
  155.        .
  156.        .
  157.        mov     drawmode,1  ; use foreground color
  158.        lea     bx,bz       ; point to bezier curve data
  159.        mov     cx,100      ; should be adequate
  160.        call    bezier
  161.  
  162.  
  163.  
  164. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  165.  
  166. BITBLOCKBYTES: calculate bytes required to save a bit block
  167. Source:        bbbytes.asm ($graph.asm)
  168.  
  169. Call with:     DS:[BX] pointing to x- and y-coordinate data (see example)
  170. Returns:       DX:AX = bytes required to save the bit block
  171.                small or medium model:
  172.                   if CF = 0, bytes required is less than 64k segment
  173.                      => no problem
  174.                   if CF = 1, bit block is too big for a 64k segment
  175.                      small or medium model BitBlock subroutines will
  176.                      not work properly
  177. Uses:          AX, DX, flags
  178. Supports:      all ASMLIB graphics modes; call BitBlockBytes while
  179.                the system is in the mode you intend to use.  Otherwise,
  180.                an incorrect byte size may be returned, leading to either
  181.                wasted memory or memory allocation errors.
  182. Example:
  183.  
  184. include asm.inc
  185.  
  186. extrn   bitblockbytes:proc
  187.  
  188. .data
  189. x0      dw 100,43         ; first corner at (100,43)
  190. x1      dw 175,143        ; second corner at (175,143)
  191.  
  192. .code
  193. ; program fragment assumes DS:@data
  194.         .
  195.         .
  196.         .
  197.         lea    bx,x0          ; DS:[BX] points to bit block corner data
  198.         call   bitblockbytes  ; returns AX = byte size of buffer required
  199.         jc     too_big        ; bit block is too big if CF = 1 (small or med)
  200.  
  201. ; note that when the huge model is used, memory greater than 64k must be
  202. ; allocated with DOS function 48h.  See STARTUP.ASM to release unused
  203. ; memory to allow DOS memory allocation.
  204.  
  205.  
  206. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  207.  
  208. BITPLANEBYTES: calculate bytes to save one plane of a bit block
  209.                alternate entry to BitBlockBytes; calculates bytes
  210.                required to save one plane of multi-plane modes
  211. Source:        bbbytes.asm ($graph.asm)
  212. Call with:     DS:[BX] pointing to x- and y-coordinate data
  213. Returns:       DX:AX = bytes required to save the bit plane
  214.                small or medium model:
  215.                   if CF = 0, bytes required is less than 64k
  216.                      => no problem
  217.                   if CF = 1, bit plane is too big for a 64k segment
  218.                      small or medium model BitPlane subroutines will
  219.                      not work properly
  220. Uses:          AX, DX, flags
  221. Supports:      all ASMLIB graphics modes; call BitPlaneBytes while
  222.                the system is in the mode you intend to use.  If the
  223.                system is is not in a multi-plane mode, BitPlaneBytes
  224.                will give you the same results as BitBlockBytes.
  225.                Graphics modes with multiple planes are mode 0Fh (2 planes)
  226.                and all 16-color modes (4 planes).
  227. Example:
  228.  
  229. include asm.inc
  230.  
  231. extrn   bitplanebytes:proc
  232.  
  233. .data
  234. x0      dw 100,43         ; first corner at (100,43)
  235. x1      dw 175,143        ; second corner at (175,143)
  236.  
  237. .code
  238. ; program fragment assumes DS:@data
  239.         .
  240.         .
  241.         .
  242.         lea    bx,x0          ; DS:[BX] points to bit block corner data
  243.         call   bitplanebytes  ; returns AX = byte size of buffer required
  244.         jc     too_big        ; unlikely
  245.  
  246.  
  247. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  248.  
  249. BUFFERDIM:     change logical buffer dimensions
  250.                does not change number of pixels displayed on screen;
  251.                used with ScreenOrigin.
  252. Source:        buffdim.asm ($graph.asm)
  253.  
  254. Call with:     DS:[BX] pointing to new buffer dimensions
  255.                Note that the logical buffer dimensions should be
  256.                greater than the dimensions displayed on the screen
  257.                The logical buffer dimensions must not create a plane size
  258.                greater than 64k; in a 16-color mode, a logical pixel width
  259.                of 800 + logical height of 600 works out to 60,000 bytes per
  260.                plane.  Horizontal dimensions must be an integer multiple
  261.                of 8.  In VGA13x modes, logical dimensions of 640 horizontal
  262.                and 400 vertical is also 60,000 bytes per plane.
  263.  
  264.                If anything is displayed on the screen before changing
  265.                logical dimensions, it will be unreadable after calling
  266.                BufferDim if your logical x-dimension is not the same as
  267.                the screen's physical x-width.
  268.  
  269.                BufferDim does not determine if the computer has an EGA or
  270.                VGA (see GetCRT in SYSTEM.DOC).
  271.  
  272. Returns:       AX = maximum number of pages available
  273. Uses:          AX, flags
  274. Supports:      EGA/VGA-type 16-color modes
  275.                VGA13x 256-color modes
  276. Example:       see next page
  277.  
  278.  
  279.  
  280. (BufferDim example)
  281.  
  282. ; The computer has a 256k EGA card & EGA-only monitor 
  283. ; and I want to display an image that is 800 pixels wide
  284. ; and 600 pixels high.
  285. ; I'll use EGA mode 10h, switch to logical dimensions of 800x600,
  286. ; put the image in the video buffer & use ScreenOrigin to view
  287. ; various parts of the image
  288.  
  289. include asm.inc
  290.  
  291. public  mysub
  292. extrn   bufferdim:proc, screenorigin:proc
  293. extrn   loadpcx:proc
  294.  
  295. .data
  296. dim     dw 800,600              ; I want 800 logical x
  297.                                 ;  & 600 logical y
  298. xy      dw 0,0                  ; screen origin always starts at (0,0)
  299. fname   db '800x600.pcx',0      ; a .PCX file with an 800 x 600 image
  300.  
  301. .code
  302. mysub   proc
  303. ; set up 640x350 16-color mode
  304.         mov    ax,10h           ; use BIOS to set mode
  305.         int    10h
  306.         lea    bx,dim           ; point to logical buffer dimensions
  307.         call   bufferdim        ; set up 800x600 logical dimensions
  308.                                 ; NOTE: only one page available
  309.  
  310. ; program loads image to video buffer
  311.         lea    dx,fname         ; point to filename
  312.         call   loadpcx          ; get image
  313.  
  314. ; default screen origin: (0,0) of buffer is at (0,0) of screen
  315. ; change portion of buffer displayed to logical (100,100)
  316. ; at (0,0) of screen
  317.         lea    bx,xy
  318.         mov    word ptr [bx],100
  319.         mov    word ptr 2[bx],100
  320.         call   screenorigin
  321.  
  322.  
  323. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  324.  
  325. CIRCLEASPECT:  modifies aspect ratio of circle
  326. Source:        $circle.asm ($graph.asm)
  327.  
  328. Call with:     AH = numerator of aspect ratio
  329.                AL = denominator of aspect ratio
  330.                AH <> 0, AL <> 0
  331.  
  332.                CircleAspect is used with DrawCircle to draw an ellipse.
  333.                An aspect ratio less than one makes a flat ellipse and an
  334.                aspect ratio greater than one makes a tall ellipse.
  335.                Aspect ratios greater than 5 or less than 1/5 may cause
  336.                unpredictable results.
  337.  
  338. Returns:       nothing
  339. Uses:          nothing; all registers and flags are saved
  340. Supports:      all ASMLIB graphics modes
  341. Example:       see DrawCircle
  342.  
  343.  
  344.  
  345. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  346.  
  347. DEFGMODE:      restore ASMLIB's internal flags to use system graphics
  348.                mode (see ForceGMode)
  349. Source:        defgmode.asm
  350.  
  351. Call with:     no parameters
  352. Returns:       nothing
  353. Uses:          nothing
  354. Supports:      all ASMLIB graphics modes
  355. Example:       see ForceGMode
  356.  
  357.  
  358.  
  359. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  360.  
  361. DRAWCIRCLE:    draw a circle
  362. Source:        drawcirc.asm ($graph.asm, $circle.asm, $putdot.asm,
  363.                 divi2.asm, mulf4.asm, invi2.asm, i2tof4.asm, f4toi2.asm)
  364.  
  365. Call with:     DS:[BX] pointing to circle center coordinates and x-radius
  366.                Drawmodes supported are:
  367.                 4 = AND the foreground color with the screen
  368.                 3 = OR the foreground color with the screen
  369.                 1, 2 = use foreground color
  370.                 0 = XOR circle with existing screen
  371.                -1, -2 = use background color
  372.                -3 = OR the background color with the screen
  373.                -4 = AND the background color with the screen
  374.                See DrawMode for more information.
  375.  
  376.                For filled circle, see FillCIrcle.
  377.  
  378. Returns:       nothing
  379. Uses:          nothing
  380. Supports:      all ASMLIB graphics modes
  381. Example:
  382.  
  383. include asm.inc
  384. extrn   drawcircle:proc, circleaspect:proc
  385.  
  386. .data
  387. xcenter dw 100              ; DrawCircle data must be words
  388. ycenter dw 100              ; the circle is centered at (100,100)
  389. xradius dw 50               ; x-dimension radius in pixels (>0)
  390.  
  391. .code
  392. ; program fragment assumes DS:@data
  393.         .
  394.         .
  395.         .
  396.         mov   ah,5
  397.         mov   al,1          ; a tall ellipse
  398.         call  circleaspect
  399.  
  400.         lea   bx,xcenter    ; DS:[BX] points to circle data
  401.         call  drawcircle    ; draw the circle
  402.  
  403.  
  404. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  405.  
  406. DRAWBOX:       draw a rectangle on a graphics screen
  407. Source:        drawbox.asm ($graph.asm, $vert.asm, $horiz.asm, several others)
  408.  
  409. Call with:     DS:[BX] pointing to box corner data
  410.                Drawmodes supported are:
  411.                 4 = AND the foreground color with the screen; color modes
  412.                 3 = OR the foreground color with the screen
  413.                 1, 2 = use foreground color: all modes
  414.                 0 = XOR foreground color with existing pixels
  415.                -1, -2 = use background color: all modes
  416.                -3 = OR the background color with the screen
  417.                -4 = AND the background color with the screen; color modes
  418.                See DrawMode for more information; see also LinePattern
  419. Returns:       nothing
  420. Uses:          nothing
  421. Supports:      all ASMLIB graphics modes
  422. Example:
  423.  
  424. include asm.inc
  425.  
  426. extrn   drawbox:proc
  427.  
  428. .data
  429. x0      dw 25,10            ; first corner at (25,10); data is word size
  430. x1      dw 301,97           ; opposite corner at (301,97)
  431.  
  432. .code
  433. ; program fragment assumes DS:@data
  434.         .
  435.         .
  436.         lea   bx,x0         ; DS:[BX] points to box corner data
  437.         call  drawbox
  438.  
  439.  
  440. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  441.  
  442. DRAWLINE:      draw a line on a graphics screen
  443. Source:        drawline.asm ($graph.asm, $vert.asm, $horiz.asm,
  444.                              $loslope.asm, $hislope.asm, many others)
  445.  
  446. Call with:     DS:[BX] pointing to line endpoint data
  447.                Drawmodes supported are:
  448.                 4 = AND the foreground color with the screen; color modes
  449.                 3 = OR the foreground color with the screen
  450.                 1, 2 = use foreground color: all modes
  451.                 0 = XOR foreground color with existing pixels
  452.                -1, -2 = use background color: all modes
  453.                -3 = OR the background color with the screen
  454.                -4 = AND the background color with the screen; color modes
  455.                See DrawMode for more information; see also LinePattern
  456. Returns:       nothing
  457. Uses:          nothing
  458. Supports:      all ASMLIB graphics modes
  459. Example:
  460.  
  461. include asm.inc
  462.  
  463. extrn   drawline:proc
  464.  
  465. .data
  466. x0      dw 25,10            ; first endpoint at (25,10); data is word size
  467. x1      dw 301,97           ; other end of line at (301,97)
  468.  
  469. .code
  470. ; program fragment assumes DS:@data
  471.         .
  472.         .
  473.         lea   bx,x0         ; DS:[BX] points to line coordinate data
  474.         call  drawline
  475.  
  476.  
  477. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  478.  
  479. DRAWMODE:      control ASMLIB graphics drawing mode
  480. Source:        $graph.asm
  481.  
  482.                DrawMode is a public byte in DGROUP used to control the
  483.                operation of many ASMLIB subroutines.  ASMLIB's default
  484.                drawmode is 1.
  485.  
  486.                Typically, drawmodes have the following effects:
  487.                 2 = use foreground color only; text is printed without
  488.                     background, foreground only of line patterns or
  489.                     fill patterns is used
  490.                 1 = use foreground and background; text is printed with
  491.                     background, line patterns and fill patterns update
  492.                     both foreground and background
  493.                 0 = foreground color is XORed with the existing screen
  494.                     (not supported in 256-color or CGA 4-color modes)
  495.                -1 = characters or fill pattern drawn with foreground
  496.                     and background reversed
  497.                -2 = character or line drawn with background color only
  498.  
  499. Supports:      all ASMLIB graphics modes
  500. Example:
  501.  
  502. include asm.inc
  503.  
  504. .data
  505. extrn   drawmode:byte
  506.  
  507. .code
  508. ; program fragment assumes DS:@data
  509.         .
  510.         .
  511.         mov     drawmode,2      ; print text with foreground color only
  512.  
  513.  
  514. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  515.  
  516. FILLAREA:      fills an irregular area on a graphics screen
  517. Source:        fillarea.asm ($graph.asm, $horiz.asm, $getdot.asm,
  518.                              several others)
  519.  
  520. Call with:     DS:[BX] pointing to seed pixel coordinates
  521.  
  522.                Fills many irregularly-shaped areas with color and/or
  523.                pattern, beginning at (x,y).  FillArea may not work
  524.                properly with regions which have concave boundaries
  525.                crossing horizontal lines.  The area's boundary is
  526.                defined by a solid line of non-zero pixels.
  527.                DrawModes supported are:
  528.                 2 = fill with foreground color only (if fill pattern
  529.                     has been defined): 16-color modes
  530.                 1 = fill with foreground (and background, if fillpattern
  531.                     defined): all modes
  532.                See also FillPattern.
  533. Returns:       nothing
  534. Uses:          nothing
  535. Supports:      all ASMLIB graphics modes
  536. Example:
  537.  
  538. include asm.inc
  539.  
  540. extrn   fillarea:proc
  541.  
  542. .data
  543. x       dw 10,15         ; start fill operation at x=10, y=15
  544.  
  545. .code
  546. ; program fragment assumes DS:@data
  547.         .
  548.         .
  549.         lea    bx,x
  550.         call   fillpattern
  551.  
  552.  
  553. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  554.  
  555. FILLBOX:       draw a filled rectangle on a graphics screen
  556. Source:        fillbox.asm ($graph.asm, $horiz.asm, several others)
  557.  
  558. Call with:     DS:[BX] pointing to box corner data
  559.                Drawmodes supported are:
  560.                 4 = AND the box with the pre-existing screen
  561.                 3 = OR the foreground color with the screen
  562.                 1, 2 = use foreground color
  563.                 0 = XOR foreground color with existing pixels
  564.                -1, -2 = use background color
  565.                -3 = OR the background color with the screen
  566.                -4 = AND the background color with pre-existing screen
  567.                See DrawMode for more information; also see FillPattern.
  568. Returns:       nothing
  569. Uses:          nothing
  570. Supports:      all ASMLIB graphics modes
  571. Example:
  572.  
  573. include asm.inc
  574.  
  575. extrn   fillbox:proc
  576.  
  577. .data
  578. x0      dw 25,10            ; first corner at (25,10); data is word size
  579. x1      dw 301,97           ; opposite corner at (301,97)
  580.  
  581. .code
  582. ; program fragment assumes DS:@data
  583.         .
  584.         .
  585.         lea   bx,x0         ; DS:[BX] points to box corner data
  586.         call  fillbox
  587.  
  588.  
  589. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  590.  
  591. FILLCIRCLE:    draw a filled circle
  592. Source:        fillcirc.asm ($graph.asm, $circle.asm, $horiz.asm,
  593.                 divi2.asm, mulf4.asm, invi2.asm, i2tof4.asm, f4toi2.asm)
  594.  
  595. Call with:     DS:[BX] pointing to circle center coordinates and x-radius
  596.                Drawmodes supported are:
  597.                 4 = AND the foreground color with the screen
  598.                 3 = OR the foreground color with the screen
  599.                 1, 2 = use foreground color
  600.                 0 = XOR circle with existing screen
  601.                -1, -2 = use background color
  602.                -3 = OR the background color with the screen
  603.                -4 = AND the background color with the screen
  604.                See DrawMode for more information.
  605.  
  606. Returns:       nothing
  607. Uses:          nothing
  608. Supports:      all ASMLIB graphics modes
  609. Example:
  610.  
  611. include asm.inc
  612. extrn   fillcircle:proc, circleaspect:proc
  613.  
  614. .data
  615. xcenter dw 100              ; FillCircle data must be words
  616. ycenter dw 100              ; the circle is centered at (100,100)
  617. xradius dw 50               ; x-dimension radius in pixels (>0)
  618.  
  619. .code
  620. ; program fragment assumes DS:@data
  621.         .
  622.         .
  623.         .
  624.         mov   ah,5
  625.         mov   al,1          ; a tall ellipse
  626.         call  circleaspect
  627.  
  628.         lea   bx,xcenter    ; DS:[BX] points to circle data
  629.         call  fillcircle    ; draw the circle
  630.  
  631.  
  632. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  633.  
  634. FILLPATTERN:   define an optional pattern for FillArea & FillBox
  635. Source:        fpattern.asm
  636.  
  637. Call with:     DS:[BX] pointing to ASCIIZ pattern string.
  638.                Up to 8 characters in the string will be used.
  639.                The pattern must be re-defined before each call to a line
  640.                drawing subroutine (FillArea, FillBox).
  641. Returns:       nothing
  642. Uses:          nothing
  643. Supports:      all ASMLIB graphics modes except 256-color modes
  644. Example:
  645.  
  646. include asm.inc
  647.  
  648. extrn   fillbox:proc
  649. extrn   fillpattern:proc
  650.  
  651. .data
  652. x0      dw 25,10            ; first corner at (25,10); data is word size
  653. x1      dw 301,97           ; opposite corner at (301,97)
  654. pattern db 8 dup(10101010b),0
  655.  
  656. .code
  657. ; program fragment assumes DS:@data
  658.         .
  659.         .
  660.         lea   bx,pattern    ; DS:[BX] points to pattern string
  661.         call  fillpattern   ; define the pattern
  662.         sub   bx,8          ; DS:[BX] points to box corner data
  663.         call  fillbox       ; draw a patterned box
  664.  
  665.  
  666. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  667.  
  668. FORCEGMODE:    force ASMLIB to use one particular graphics mode
  669.                this is handy for two-monitor systems
  670. Source:        defgmode.asm
  671.  
  672. Call with:     AL = graphics mode to use
  673.                forcegmode does not change the actual screen mode; what
  674.                it does is to force ASMLIB's central graphics control
  675.                to ignore the system mode.  Call defgmode to restore
  676.                ASMLIB's internal flags to the default state.
  677. Returns:       nothing
  678. Uses:          nothing
  679. Supports:      all ASMLIB graphics modes (256-color modes not tested)
  680. Example:
  681.  
  682. include asm.inc
  683.  
  684. extrn   modecolor:proc, modemono:proc
  685. extrn   forcegmode:proc, gcolor:proc, defgmode:proc
  686.  
  687. .data
  688. gtext   db 'Graphics mode',0
  689. gpos    dd 0                   ; 2 words of zeros to position text
  690. ttext   db 'Text mode',0
  691.  
  692. .code
  693. ; program fragment assumes DS:@data
  694. ; I want text on the monochrome screen and 16-color graphics on the EGA
  695.         call   modecolor       ; switch to color monitor
  696.         mov    ax,10h          ; set up graphics mode
  697.         int    10h
  698.         mov    al,10h          ; tell ASMLIB to use mode 10h
  699.                                ; use AL = 13h for VGA 256-color modes
  700.                                ; use AL = 8 for Hercules (including InColor)
  701.         call   forcegmode      ; best to do this after the mode change
  702.         call   modemono        ; switch back to the monochrome monitor
  703.         mov    ax,010Ch        ; blue background, red foreground
  704.         call   gcolor
  705.         lea    si,gtext        ; point to graphics message
  706.         lea    dx,gpos         ; positioned at upper left corner
  707.         call   gprint          ; prints on EGA in graphics mode
  708.  
  709.         lea    si,ttext        ; point to text message
  710.         xor    dx,dx           ; upper left corner of text screen
  711.         mov    ah,7            ; normal color
  712.         call   tprint          ; display message on monochrome monitor
  713.         .
  714.         .
  715. ; sometime later, all done with this setup
  716.         call   defgmode        ; clear ASMLIB's internal graphics flags
  717.  
  718.  
  719. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  720.  
  721. GBASESEG:      change ASMLIB graphics base segment
  722. Source:        gbaseseg.asm ($graph.asm)
  723.  
  724. Call with:     AX = base segment address for alternate buffer
  725.                if AX = 0, default base segment is restored
  726.                GBaseSeg may be used to create and update off-screen graph
  727.                images, thus simulating multiple screen pages.
  728. Returns:       nothing
  729. Uses:          nothing
  730. Supports:      mode 04h, 05h, HGraph (monochrome only), 40h, 11h, 13h
  731.  
  732.                buffer size requirements:
  733.  
  734.                 mode 04h, 05h    16384 bytes
  735.                 HGraph, 40h      32768 bytes
  736.                 mode 11h         38400 bytes
  737.                 mode 13h         64000 bytes
  738.  
  739.                 GBaseSeg may also work with planar or bank-switched
  740.                 modes in a windowing multi-tasking environment, such
  741.                 as DesqView.  Feedback, please!!
  742.                 You must call GBaseseg AFTER switching the system to graphics
  743.                 mode, or it will not work; you must also call GBaseSeg with
  744.                 AX = 0 before changing from one graphics mode to another, or
  745.                 the default base segment may get messed up.
  746. Example:
  747.  
  748. .model medium
  749.  
  750. public myprog
  751. extrn  gbaseseg:proc, drawbox:proc
  752.  
  753. .data
  754. boxdata dw 0,0,319,199
  755.  
  756. .fardata
  757. screen1 db 64000 dup (0)     ; second screen for mode 13h
  758.  
  759. .code
  760. myprog proc
  761. ; program fragment assumes DS:@DATA
  762. ; mode 13h, 320x200x256 colors
  763.        mov     ax,13h
  764.        int     10h
  765. ; use alternate buffer
  766.        mov     ax,seg screen1
  767.        call    gbaseseg
  768.        lea     bx,linedata
  769.        call    drawbox
  770.  
  771. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  772.  
  773. GCENTER:       centers a string on a graphics screen
  774. Source:        gcenter.asm (gprint.asm, $graph.asm, strlen.asm, f8x14.asm)
  775.  
  776. GCENTERX:      centers a double-width string on a graphics screen
  777. Source:        gcenterx.asm (gprintx.asm, $graph.asm, strlen.asm, f8x14.asm)
  778.  
  779. Call with:     DS:[SI] pointing to the string to print
  780.                DS:[DX] pointing to x- and y-coordinates
  781.                the x-coordinate is a placeholder; GCenter calculates the
  782.                correct x value before calling GPrint.
  783.  
  784.                Colors, drawmodes and character sizes are the same as
  785.                for GPrint or GPrintX.
  786. Returns:       x = calculated x-coordinate
  787. Uses:          nothing; all registers and flags are saved.
  788. Supports:      all ASMLIB graphics modes
  789. Example:
  790.  
  791. include asm.inc
  792.  
  793. extrn   gcenter:proc
  794.  
  795. .data
  796. x       dw ?
  797. y       dw 2               ; print graph title 2 pixels down from the top
  798. title   db 'Graph title',0
  799.  
  800. .code
  801. ; program fragment assumes DS:@data
  802.         .
  803.         .
  804.         lea    si,title    ; DS:[SI] points to string
  805.         lea    dx,x        ; point to coordinates
  806.         call   gcenter     ; print the string, centered horizontally
  807.  
  808.  
  809. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  810.  
  811. GCLEAR:        clears the active portion of a graphics screen
  812.                uses background color
  813. Source:        gclear.asm ($graph.asm, $horiz.asm, others)
  814.  
  815. Call with:     no parameters
  816. Returns:       nothing
  817. Uses:          nothing
  818. Supports:      all ASMLIB graphics modes
  819. Example:
  820.  
  821. include asm.inc
  822.  
  823. extrn   gclear:proc
  824.  
  825. .code
  826.         .
  827.         .
  828.         .
  829.         call  gclear
  830.  
  831. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  832.  
  833. GCOLOR:        update color used by ASMLIB graphics
  834. Source:        gcolor.asm ($graph.asm)
  835.  
  836. Call with:     AL = foreground color
  837.                AH = background color
  838.  
  839.                for 4-color modes, colors may be 0-3
  840.                for 16-color modes, colors may be 0-15
  841.                for 256-color modes, colors may be 0-255
  842.  
  843. Returns:       nothing
  844. Uses:          nothing
  845. Supports:      all color graphics modes and mode 0Fh
  846.                GColor is ignored by 2-color modes
  847. Example:
  848.  
  849. include asm.inc
  850.  
  851. extrn   gcolor:proc
  852.  
  853. .code
  854.         .
  855.         .
  856.         .
  857.         mov   ah,bcolor      ; background color
  858.         mov   al,fcolor      ; foreground color
  859.         call  gcolor
  860.  
  861.  
  862. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  863.  
  864. GCOPY:         copies one page of graphics memory to another
  865. Source:        gcopy.asm ($graph.asm)
  866.  
  867. Call with:     BH = frompage
  868.                BL = topage
  869. Returns:       CF = error flag
  870.                 if CF = 0, no error
  871.                 if CF = 1, bad page number or frompage = topage
  872. Uses:          AX, CF
  873. Supports:      Hercules and InColor (with Use64k)
  874.                EGA/VGA modes 0Dh, 0Eh, 0Fh, 10h
  875.                VGA13X [0,1,2]
  876. Example:
  877.  
  878. include asm.inc
  879.  
  880. extrn   gcopy:proc
  881.  
  882. .code
  883.         .
  884.         .
  885.         .
  886.         mov   bx,0001h       ; copy from page 0 to page 1
  887.         call  gcopy
  888.         jc    bad_page       ; uh oh, pages not supported
  889.  
  890.  
  891. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  892.  
  893. GCURSOR:       simulate text-mode cursor on graphics screen
  894. GUCURSOR:      simulate underscore cursor on graphics screen
  895. Source:        gcursor.asm ($graph.asm)
  896.  
  897. Call with:     DS:[DX] pointing to x- and y-coordinate word data
  898.                x and y are the coordinates of the UPPER LEFT corner of
  899.                a character block.  Note that text characters are
  900.                8 x-pixels wide and from 8 to 16 y-pixels high.
  901.  
  902.                GCursor and GUCursor maintain the simulated cursor while
  903.                the keyboard type-ahead buffer is empty.  GCursor shape
  904.                is an underscore when INSERT is off and a larger block
  905.                when INSERT is on.  GUCursor is an underscore regardless
  906.                of the state of the INSERT toggle.
  907. Returns:       nothing
  908. Uses:          AX, CX
  909. Supports:      all ASMLIB graphics modes
  910. Example:
  911.  
  912. include asm.inc
  913.  
  914. extrn   gcursor:proc, getkey:proc
  915.  
  916. .data
  917. x       dw 10,20        ; put the cursor in the character block at (10,20)
  918.  
  919. .code
  920. ; program fragment assumes DS:@data
  921.         .
  922.         .
  923.         .
  924.         lea   dx,x
  925.         call  gcursor
  926.         call  getkey    ; retrieve the key that was pressed
  927.  
  928.  
  929. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  930.  
  931. GETBITBLOCK:   saves a portion of a graphics screen in memory
  932. Source:        bitblock.asm ($graph.asm, bb02.asm, bb04.asm, bb06.asm,
  933.                              bb08.asm, bb10.asm, bb12.asm, bb14.asm,
  934.                              lowES2hi.asm, lowDS2hi.asm)
  935.  
  936. Call with:     ES:[DI] pointing to memory buffer for the bit block
  937.                DS:[BX] pointing to x & y coordinate data
  938.  
  939.                Note that a bit block copied from a 4-plane mode may
  940.                only be restored to a 4-plane mode; likewise, a bit
  941.                block saved from a 2-color mode should be restored to
  942.                a 2-color mode or to a single bit plane of a 16-color
  943.                mode.
  944. Returns:       nothing
  945. Uses:          nothing
  946. Supports:      all ASMLIB graphics modes
  947.                memory models: small medium, huge
  948.  
  949.  
  950.     If you do not intend to support all ASMLIB graphics modes, you can
  951.     call mode-specific BitBlock subroutines to reduce .EXE size.
  952.     These subroutines use the same calling parameters as GetBitBlock
  953.     and PutBitBlock:
  954.  
  955.  
  956.     getbb02: mode 04h, 05h, 11h, 40h, HGraph (mono and InColor)
  957.     getbb06: mode 0Dh, 0Eh, 0Fh, 10h, 12h, SVGA16(0), XMODE16
  958.     getbb08: mode 13h
  959.     getbb10: VGA13X
  960.     getbb12: SVGA16
  961.     getbb14: SVGA256
  962.  
  963.  
  964.     putbb02: mode 04h, 05h, 11h, 40h, HGraph (mono only)
  965.     putbb04: HGraph (InColor only)
  966.     putbb06: mode 0Dh, 0Eh, 0Fh, 10h, 12h, SVGA16(0), XMODE16
  967.     putbb08: mode 13h
  968.     putbb10: VGA13X
  969.     putbb12: SVGA16
  970.     putbb14: SVGA256
  971.  
  972. Example on next page
  973.  
  974.  
  975. ; example of GetBitBlock use
  976.  
  977. include asm.inc
  978.  
  979. extrn   bitblockbytes:proc, getbitblock:proc, putbitblock:proc
  980. extrn   halloc:proc
  981.  
  982. .data
  983. ptr     dw ?                ; use this to save pointer to bit block
  984. x0      dw 100,43,175,143   ; save from (100,43) to (175,143)
  985.  
  986. .code
  987. ; program fragment assumes DS:@data
  988.         .
  989.         .
  990.         lea   bx,x0         ; point to block corners
  991.         call  bitblockbytes ; calculate byte requirement
  992.         jc    too_big       ; error control
  993.         call  halloc        ; this example allocate the buffer from heap
  994.                             ; can't do this w/ huge bit blocks
  995.         jc    no_memory     ; more error control
  996.         mov   ptr,bx        ; save near address of bit block
  997.         push  ds
  998.         pop   es            ; ES = DS
  999.         mov   di,bx         ; ES:[DI] points to buffer
  1000.         lea   bx,x0         ; DS:[BX] points to coordinate data
  1001.         call  getbitblock
  1002.         .
  1003.         .
  1004.  
  1005. ; later . . .
  1006.         lea   bx,x0         ; put the bit block back where you found it
  1007.         push  ds
  1008.         pop   es            ; ES = DS
  1009.         mov   di,ptr        ; ES:[DI] points to buffer
  1010.         call  putbitblock
  1011.  
  1012. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1013.  
  1014. GETBITPLANE:   saves one plane of a bit block in memory
  1015. Source:        small & medium: bitplane.asm ($graph.asm, bb02.asm, bb04.asm
  1016.                                bb06.asm, bb08.asm, bb10.asm, bb12.asm,
  1017.                                bb14.asm)
  1018.                huge: same as small & medium, + lowES2hi.asm & lowDS2hi.asm
  1019.  
  1020. Call with:     ES:[DI] pointing to memory buffer for the bit block
  1021.                DS:[BX] pointing to x & y coordinate data
  1022.                AL = plane number to save
  1023.                valid plane numbers are 0 - 3 in 16-color modes
  1024.                                        0 & 2 in EGA monochrome mode
  1025.  
  1026.                In 16-color modes, EGA/VGA and InColor planes are:
  1027.                 0 = blue, 1 = green, 2 = red, 3 = gray (or intensity)
  1028.                In EGA monochrome mode, plane 0 = normal, plane 2 = blink
  1029.                 or intensity
  1030.                The actual colors each plane represents may change
  1031.                depending on the values in the pallete registers.
  1032.  
  1033. Supports:      all 16-color modes plus EGA monochrome
  1034.                other modes: GetBitPlane works like GetBitBlock
  1035.                memory models: small, medium, huge
  1036.  
  1037.  
  1038. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1039.  
  1040. GETVIEW:       returns a pointer to the current view coordinates for
  1041.                the active page
  1042. Source:        getview.asm ($graph.asm)
  1043.  
  1044. Call with:     no parameters
  1045.                most ASMLIB subroutines, except the GPrint series, GLoad,
  1046.                GCopy and GSave, limit their activity to the view region.
  1047.                You may use the returned pointer to change the active
  1048.                portion of the screen; be careful not to exceed the maximum
  1049.                x1 and y1 values permitted by the current mode.  Also, x0
  1050.                must always be less than x1 and y0 must always be less than
  1051.                y1.
  1052.                ASMLIB's defaults are:
  1053.                 x0 = 0
  1054.                 y0 = 0
  1055.                 x1 = xmax
  1056.                 y1 = ymax
  1057.  
  1058.                See also ResetView
  1059.  
  1060. Returns:       ES:[BX] pointing to the current view coordinates
  1061. Uses:          ES, BX; all other registers and flags are saved
  1062. Supports:      all ASMLIB graphics modes and pages
  1063. Example:
  1064.  
  1065. include asm.inc
  1066.  
  1067. extrn   getview:proc
  1068.  
  1069. x0 EQU word ptr ES:[BX]
  1070. y0 EQU word ptr ES:2[BX]
  1071. x1 EQU word ptr ES:4[BX]
  1072. y1 EQU word ptr ES:6[BX]
  1073.  
  1074. .code
  1075.         .
  1076.         .
  1077.         .
  1078.         call   getview
  1079.  
  1080.  
  1081. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1082.  
  1083. GETDOT:        determine pixel value on graphics screen
  1084. Source:        getdot.asm ($graph.asm, $getdot.asm, others)
  1085.  
  1086. Call with:     DS:[BX] pointing to pixel coordinate data
  1087. Returns:       if CF = 0, AX = pixel value
  1088.                if CF = 1, pixel coordinates outside active view area
  1089. Uses:          AX, CF
  1090. Supports:      all ASMLIB graphics modes
  1091. Example:
  1092.  
  1093. include asm.inc
  1094.  
  1095. extrn   getdot:proc
  1096.  
  1097. .data
  1098. x       dw 10,10             ; pixel at (10,10)
  1099.  
  1100. .code
  1101. ; program fragment assumes DS:@data
  1102.         .
  1103.         .
  1104.         .
  1105.         lea    bx,x          ; point to pixel coordinates
  1106.         call   getdot        ; get pixel value
  1107.         jc     out_of_bounds ; oops
  1108.  
  1109.  
  1110.  
  1111. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1112.  
  1113. GLOAD:         loads a graphics screen saved as a disk file by GSave
  1114. Source:        gsave.asm ($graph.asm, $gbytes.asm, $reset.asm)
  1115.  
  1116. Call with:     DS:[DX] pointing to the name of the file to load
  1117.                the filename must be an ASCIIZ string
  1118. Returns:       AX = MS-DOS error code
  1119. Uses:          AX, BX, CX, flags
  1120. Supports:      all ASMLIB graphics modes
  1121. Example:
  1122.  
  1123. include asm.inc
  1124.  
  1125. extrn   gload:proc
  1126.  
  1127. .data
  1128. filename db 'graph.bin',0
  1129.  
  1130. .code
  1131. ; program fragment assumes DS:@data
  1132.         .
  1133.         .
  1134.         lea   dx,filename
  1135.         call  gload
  1136.  
  1137.  
  1138. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1139.  
  1140. GLOADEMS:      loads a graphics screen saved in EMS memory by GSaveEMS
  1141. Source:        gloadems.asm ($graph.asm, ems.asm, $gbytes.asm, $emspage.asm
  1142.                              banks.asm, $reset.asm, emputget.asm, $plane.asm,
  1143.                              $gloadx.asm, $plane.asm)
  1144.  
  1145. Call with:     BX = EMS handle
  1146.                assumes DS:@data
  1147. Returns:       if CF = 0, no error
  1148.                if CF = 1, AH = EMS error code
  1149. Uses:          AX, flags
  1150. Supports:      all ASMLIB graphics modes
  1151. Example:
  1152.  
  1153. include asm.inc
  1154.  
  1155. public  testems
  1156.  
  1157. extrn   mode43:proc, getkey:proc, isems:proc, gsaveems:proc, gloadems:proc
  1158.  
  1159. .data
  1160. handle  dw 0
  1161.  
  1162. .code
  1163. testems proc
  1164.         mov     ax,12h          ; VGA 16-color mode
  1165.         int     10h
  1166.         .
  1167.         .
  1168.         .
  1169. ; program draws screen
  1170.         .
  1171.         .
  1172.         call    isems
  1173.         jc      no_ems
  1174.         call    gsaveems
  1175.         jc      no_ems
  1176.         mov     handle,bx
  1177.         .
  1178.         .
  1179. ; some time later ...
  1180.         mov     bx,handle
  1181.         call    gloadems
  1182.         jc      kill_ems
  1183.         call    getkey
  1184. kill_ems:
  1185.         mov     dx,handle
  1186.         mov     ah,45h          ; EMS function: de-allocate block
  1187.         int     67h
  1188.  
  1189. no_ems: call    mode43
  1190.         ret
  1191. testems endp
  1192.         end
  1193.  
  1194.  
  1195. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1196.  
  1197. GLOADXMS:      loads a graphics screen saved in XMS memory by GSaveXMS
  1198. Source:        gloadxms.asm ($graph.asm, xms.asm, $gbytes.asm, $gloadx.asm,
  1199.                              banks.asm, $reset.asm, xmputget.asm, $plane.asm)
  1200.  
  1201. Call with:     BX = XMS handle
  1202.                assumes DS:@data
  1203. Returns:       if CF = 0, no error
  1204.                if CF = 1, AH = XMS error code
  1205. Uses:          AX, flags
  1206. Supports:      all ASMLIB graphics modes
  1207. Example:
  1208.  
  1209. include asm.inc
  1210.  
  1211. public  testxms
  1212.  
  1213. extrn   mode43:proc, getkey:proc, isxms:proc, gsavexms:proc, gloadxms:proc
  1214. extrn   freexms:proc
  1215.  
  1216. .data
  1217. handle  dw 0
  1218.  
  1219. .code
  1220. testxms proc
  1221.         mov     ax,12h          ; VGA 16-color mode
  1222.         int     10h
  1223.         .
  1224.         .
  1225.         .
  1226. ; program draws screen
  1227.         .
  1228.         .
  1229.         call    isxms
  1230.         jc      no_xms
  1231.         call    gsavexms
  1232.         jc      no_xms
  1233.         mov     handle,bx
  1234.         .
  1235.         .
  1236. ; some time later ...
  1237.         mov     bx,handle
  1238.         call    gloadxms
  1239.         jc      kill_xms
  1240.         call    getkey
  1241. kill_xms:
  1242.         mov     bx,handle
  1243.         call    freexms
  1244.  
  1245. no_xms: call    mode43
  1246.         ret
  1247. testxms endp
  1248.         end
  1249.  
  1250.  
  1251. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1252.  
  1253. GPAGE:         changes active and displayed graphics page
  1254.                GPage changes ASMLIB's default graphics page and displays
  1255.                the page.  See also UseGPage and ShowGPage.
  1256. Source:        gpage1.asm ($graph.asm, $herc.asm, gpage.asm)
  1257.  
  1258. Call with:     BL = page number.  See table at start of this GRAPHICS.DOC
  1259.                file.
  1260. Returns:       if CF = 0, no problem
  1261.                if CF = 1, bad page number requested
  1262. Uses:          CF
  1263. Supports:      EGA, VGA, Hercules, InColor: modes with more than one page
  1264. Example:
  1265.  
  1266. include asm.inc
  1267.  
  1268. extrn   gpage:proc
  1269.  
  1270. .code
  1271.         .
  1272.         .
  1273.         mov    bl,1          ; use and show page 1
  1274.         call   gpage
  1275.         jc     oops          ; uh oh, wrong mode
  1276.  
  1277. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1278.  
  1279. GPRINT:        prints ASCIIZ string on a graphics screen
  1280. Source:        gprint.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1281.                            $gp06.asm, $gp08.asm, $gp10.asm, others)
  1282.  
  1283. Call with:     DS:[SI] pointing to the ASCIIZ string
  1284.                DS:[DX] pointing to x- and y-coordinate data
  1285.                drawmodes supported by GPrint are:
  1286.                 2 = foreground only; background pixels left alone
  1287.                 1 = foreground and background pixels updated with
  1288.                     current gcolor
  1289.                 0 = foreground color is XORed with the existing screen
  1290.                -1 = like drawmode 1, but foreground and background reversed
  1291.                -2 = like drawmode 2, but uses background color
  1292.                Any pixel position may be specified; does not wrap around
  1293.                from right side of screen to left.  Default character size
  1294.                is 8x8 for CGA modes and modes 0Dh, 0Eh and 13h, 8x14 for
  1295.                others.
  1296.                High ASCII characters are undefined in 8x8 pixel modes
  1297.                unless you call SmallText sometime earlier in the program.
  1298. Returns:       nothing
  1299. Uses:          CX; all other registers and flags are saved
  1300. Supports:      all ASMLIB graphics modes
  1301.                not all drawmodes supported with CGA modes 04h and 05h
  1302. Example:
  1303.  
  1304. include asm.inc
  1305.  
  1306. extrn   gprint:proc
  1307.  
  1308. .data
  1309. string  db 'print this, if you will',0
  1310. gpos    dw 0,0                          ; print at upper left corner
  1311.  
  1312. .code
  1313. ; program fragment assumes DS:@data
  1314.         .
  1315.         .
  1316.         .
  1317.         lea   si,string
  1318.         lea   dx,gpos
  1319.         call  gprint
  1320.  
  1321. additional GPRINT information on next page
  1322.  
  1323. GPRINT will work with user-defined fonts up to 16 pixel rows high in all
  1324. modes with ymax > 200.  GPRINT reads a public data area in DGROUP to
  1325. determine the SEGMENT:OFFSET address of the font data, the number of pixel
  1326. rows per character and the byte increment between sucessive character
  1327. definitions.  Characters must be 8 pixels wide.
  1328.  
  1329. FONTDATA.ASM has the required font data:
  1330.  
  1331. public  f14seg
  1332. f14seg  dw SEG f8x14    ; segment address of user-loaded font (8x14 default)
  1333.         dw OFFSET f8x14 ; offset address of user-loaded font (8x14 default)
  1334.         db 14           ; byte size of character
  1335.         db 14           ; bytes from start of one char to start of next
  1336.  
  1337. Example:
  1338.  
  1339. include asm.inc
  1340.  
  1341. .data
  1342. extrn   f14seg:word
  1343.  
  1344. fname   db 'c:\ramfont\italics.fnt',0   ; 8x14 characters
  1345. fbuffer db 4096 dup (0)                 ; all RAMFont fonts are 4096 bytes
  1346. ; the fonts supplied by Hercules with the Graphics Card Plus and InColor
  1347. ; card are a variety of sizes, but in each font file the byte increment
  1348. ; is always 16 bytes
  1349.  
  1350. .code
  1351.         .
  1352.         .
  1353.         mov     ax,@data
  1354.         mov     ds,ax
  1355.         lea     dx,fname
  1356.         mov     ax,3D00h        ; open file for read
  1357.         int     21h
  1358.         mov     bx,ax           ; copy file handle to BX
  1359.         lea     dx,fbuffer      ; DS:[DX] points to buffer
  1360.         mov     cx,4096
  1361.         mov     ah,3Fh          ; read file
  1362.         int     21h
  1363.         mov     ah,3Eh          ; close file
  1364.         int     21h
  1365.         mov     f14seg,ds      ; update segment address of new font
  1366.         mov     f14seg+2,dx    ; update offset address of new font
  1367.         mov     f14seg+4,(16 shl 8) OR 14
  1368.                                 ; 14-pixel row character
  1369.                                 ; 16 bytes between character definitions
  1370.  
  1371. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1372.  
  1373. GPRINTDOWN:    prints ASCIIZ string vertically on graph screen
  1374. GPRINTUP:      prints ASCIIZ string vertically on graph screen
  1375. Source:        gprint.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1376.                            $gp06.asm, $gp08.asm, $gp10.asm, others)
  1377.  
  1378. Call with:     same as GPrint
  1379.                rotates each character 90 degrees and prints from top
  1380.                downward or from bottom upward.  Character size 8x8.
  1381.  
  1382.                Returned data and registers used same as GPrint
  1383. Example:       see GPrint.
  1384.  
  1385.  
  1386. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1387.  
  1388. GPRINTX:       print string on a graphics screen, double width
  1389. GPRINT2X:      print string on a graphics screen, double size
  1390. GPRINTDOWNX:   print string vertically on graph screen, 2x width
  1391. GPRINTDOWN2X:  print string vertically on graph screen, 2x size
  1392. GPRINTUPX:     print string vertically on graph screen, 2x width
  1393. GPRINTUP2X:    print string vertically on graph screen, 2x size
  1394. Source:        gprintx.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1395.                             $gp06.asm, $gp08.asm, $gp10.asm, others)
  1396.  
  1397.  
  1398.                Variations of GPrint and GPrintDOWN/GPrintUP;
  1399.                GPrintx, GPrintDOWNx and GPrintUPx print characters
  1400.                which are twice as wide as normal; 2x subroutines
  1401.                print the characters twice as wide and twice as high
  1402.                as normal.
  1403.  
  1404.                Parameters, supported modes and drawmodes are same as
  1405.                GPrint.  GPrintx and GPrint2x also work with user-defined
  1406.                fonts.  See GPrint.
  1407. Example:       see GPrint.
  1408.  
  1409.  
  1410. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1411.  
  1412. GPUTCHR:       print a single character on graphics screen
  1413. Source:        gputchr.asm (gprint.asm)
  1414.  
  1415. Call with:     DS:[DX] pointing to (x,y) coordinate data
  1416.                AL = character to print
  1417. Returns:       nothing
  1418. Uses:          CX
  1419. Supports:      all ASMLIB graphics modes
  1420. Example:
  1421.  
  1422. include asm.inc
  1423.  
  1424. public  mycode
  1425. extrn   gputchr:proc
  1426.  
  1427. .data
  1428. xy      dw 10,10        ; (x,y) coordinates for character
  1429.  
  1430. .code
  1431. mycode  proc
  1432. ; program fragment assumes screen in graphics mode
  1433.         .
  1434.         .
  1435.         .
  1436.         lea     dx,xy   ; DS:[DX] points to coordinate data
  1437.         mov     al,'A'
  1438.         call    gputchr
  1439.         .
  1440.         .
  1441.         .
  1442.         ret
  1443. mycode  endp
  1444.         end
  1445.  
  1446.  
  1447.  
  1448. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1449.  
  1450. GSAVE:         saves a graphics screen as a disk file
  1451.                does not compress image
  1452. Source:        gsave.asm ($graph.asm, $gbytes.asm, $reset.asm)
  1453.  
  1454. Call with:     DS:[DX] pointing to ASCIIZ filename
  1455.                disk space requirements vary depending on graphics mode:
  1456.  
  1457.                  HGraph  (mono)       32,768 bytes
  1458.                  HGraph  (InColor)   131,072 bytes
  1459.                  VGA13X(0)            64,000 bytes
  1460.                  VGA13X(1)            76,800 bytes
  1461.                  VGA13X(2)           128,000 bytes
  1462.                  VGA13X(3)           172,800 bytes
  1463.                  XMode16  varies; up to 240,000 bytes
  1464.                  VESA6Ah, SVGA16(0)  240,000 bytes
  1465.                  SVGA16(1)           393,216 bytes
  1466.                  SVGA256(0)          256,000 bytes
  1467.                  SVGA256(1)          307,200 bytes
  1468.                  SVGA256(2)          480,000 bytes
  1469.                  SVGA256(3)          786,432 bytes
  1470.                  04h/05h/06h          16,384 bytes
  1471.                  40h                  32,768 bytes
  1472.                  0Dh                  32,000 bytes
  1473.                  0Eh                  64,000 bytes
  1474.                  0Fh                  56,000 bytes
  1475.                  10h                 112,000 bytes
  1476.                  11h                  38,400 bytes
  1477.                  12h                 153,600 bytes
  1478.                  13h                  64,000 bytes
  1479.  
  1480. Returns:       if AX <> 0, AX = MS-DOS error code
  1481.                if AX = 0, no error
  1482. Uses:          AX, flags
  1483. Supports:      all ASMLIB graphics modes
  1484. Example:
  1485.  
  1486. include asm.inc
  1487.  
  1488. extrn   gsave:proc
  1489.  
  1490. .data
  1491. filename db 'graph.bin',0
  1492.  
  1493. .code
  1494. ; program fragment assumes DS:@data
  1495.         .
  1496.         .
  1497.         .
  1498.         lea   dx,filename         ; point to ASCIIZ filename
  1499.         call  gsave               ; save graph
  1500.         or    ax,ax               ; was there a problem?
  1501.         jnz   oops                ; do some error control if so
  1502.  
  1503. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1504.  
  1505. GSAVEEMS:      copies the graphics screen buffer to EMS memory; does not
  1506.                compress the image
  1507. Source:        gsaveems.asm ($graph.asm, ems.asm, $gbytes.asm, $emspage.asm
  1508.                              banks.asm, $reset.asm, emputget.asm, $plane.asm
  1509.                              $gsavex.asm)
  1510.  
  1511. Call with:     no parameters; you should use IsEMS before calling this
  1512.                subroutine to determine if EMS memory is installed.  Memory
  1513.                required is tha same as for GSave, above.
  1514. Returns:       if CF = 0, BX = EMS handle
  1515.                if CF = 1, AH = EMS error code
  1516. Uses:          AX, BX, flags
  1517. Supports:      all ASMLIB graphics modes
  1518. Example:
  1519.  
  1520. include asm.inc
  1521.  
  1522. public  testems
  1523. extrn   mode43:proc, getkey:proc, isems:proc, gsaveems:proc, gloadems:proc
  1524.  
  1525. .data
  1526. handle  dw 0
  1527.  
  1528. .code
  1529. testems proc
  1530.         mov     ax,12h          ; VGA 16-color mode
  1531.         int     10h
  1532.         .
  1533.         .
  1534. ; program draws screen
  1535.         .
  1536.         call    isems
  1537.         jc      no_ems
  1538.         call    gsaveems
  1539.         jc      no_ems
  1540.         mov     handle,bx
  1541.         .
  1542.         .
  1543. ; some time later ...
  1544.         mov     bx,handle
  1545.         call    gloadems
  1546.         jc      kill_ems
  1547.         call    getkey
  1548. kill_ems:
  1549.         mov     dx,handle
  1550.         mov     ah,45h          ; EMS function: de-allocate block
  1551.         int     67h
  1552.  
  1553. no_ems: call    mode43
  1554.         ret
  1555. testems endp
  1556.         end
  1557.  
  1558. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1559.  
  1560. GSAVEXMS:      copies the graphics screen buffer to XMS memory; does not
  1561.                compress the image
  1562. Source:        gsavexms.asm ($graph.asm, xms.asm, $gbytes.asm, $gsavex.asm,
  1563.                              banks.asm, $reset.asm, xmputget.asm, $plane.asm)
  1564.  
  1565. Call with:     no parameters; you must use IsXMS before calling this
  1566.                subroutine to determine if XMS memory is installed.  Memory
  1567.                required is tha same as for GSave, above.
  1568. Returns:       if CF = 0, BX = XMS handle
  1569.                if CF = 1, AH = XMS error code
  1570. Uses:          AX, BX, flags
  1571. Supports:      all ASMLIB graphics modes
  1572. Example:
  1573.  
  1574. include asm.inc
  1575.  
  1576. public  testxms
  1577. extrn   mode43:proc, getkey:proc, isxms:proc, gsaveems:proc, gloadxms:proc
  1578. extrn   freexms:proc
  1579.  
  1580. .data
  1581. handle  dw 0
  1582.  
  1583. .code
  1584. testxms proc
  1585.         mov     ax,12h          ; VGA 16-color mode
  1586.         int     10h
  1587.         .
  1588.         .
  1589. ; program draws screen
  1590.         .
  1591.         call    isxms
  1592.         jc      no_xms
  1593.         call    gsavexms
  1594.         jc      no_xms
  1595.         mov     handle,bx
  1596.         .
  1597.         .
  1598. ; some time later ...
  1599.         mov     bx,handle
  1600.         call    gloadxms
  1601.         jc      kill_xms
  1602.         call    getkey
  1603. kill_xms:
  1604.         mov     bx,handle
  1605.         call    freexms
  1606.  
  1607. no_xms: call    mode43
  1608.         ret
  1609. testxms endp
  1610.         end
  1611.  
  1612. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1613.  
  1614. LINEPATTERN:   defines an optional pattern for DrawLine and DrawBox
  1615. Source:        lpattern.asm ($graph.asm)
  1616.  
  1617. Call with:     DS:[BX] pointing to an ASCIIZ string of up to 8 characters.
  1618.                The bit patterns in each character are used to make dashed
  1619.                or dotted lines. For drawmodes > 0, each pixel in the line
  1620.                is updated with the foreground color if the corresponding
  1621.                bit in the bit pattern is 1.  If the bit in the bit pattern
  1622.                is 0, the corresponding pixel in the line is treated as a
  1623.                background pixel.  LinePattern must be called before each
  1624.                call to a subroutine in drawline.obj if you want the line
  1625.                pattern to be used.
  1626.  
  1627.                drawmodes supported are:
  1628.                (monochrome modes)
  1629.                 2 = update foreground pixels only
  1630.                 1 = update foreground and background pixels
  1631.                 0 = XOR the foreground color with the existing image
  1632.                -1 = like drawmode 1, but foreground and background colors
  1633.                     are reversed
  1634.                -2 = like drawmode 2, but foreground and background colors
  1635.                     are reversed
  1636.                (color modes)
  1637.                same as monochrome, plus:
  1638.                 3 = OR the foreground pixels with the pre-existing screen
  1639.                -3 = OR the background pixels with the pre-existing screen
  1640.                 4 = AND the foreground pixels with the pre-existing screen
  1641.                -4 = AND the background pixels with the pre-existing screen
  1642.  
  1643. Returns:       nothing
  1644. Uses:          nothing
  1645. Supports:      all ASMLIB graphics modes
  1646. Example:
  1647.  
  1648. include asm.inc
  1649.  
  1650. extrn   linepattern:proc, drawline:proc
  1651.  
  1652. .data
  1653. x0      dw 25,10,301,97          ; line endpoints at (25,10) & (301,97)
  1654. pattern db 4 dup(32,64),0        ; 8 bytes past x0
  1655.  
  1656. .code
  1657. ; program fragment assumes DS:@data
  1658.         .
  1659.         .
  1660.         lea   bx,pattern         ; DS:[BX] points to bit pattern
  1661.         call  linepattern        ; let drawline know what pattern to use
  1662.         sub   bx,8               ; point to line endpoint data
  1663.         call  drawline           ; draw a patterned line
  1664.  
  1665. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1666.  
  1667. LOADPCX:       reads a .PCX-format file from disk and unpacks to screen
  1668. Source:        loadpcx.asm ($graph.asm, allocdos.asm, color16.asm,
  1669.                             fopen.asm, fseek.asm, fget.asm, fgetchr.asm,
  1670.                             $plane.asm, $reset.asm)
  1671.  
  1672. Call with:     DS:[DX] pointing to ASCIIZ filename of .PCX file
  1673.                LoadPCX assumes that the video system is in an appropriate
  1674.                mode for the image; see PCXInfo (GRAPHICS.DOC).
  1675.                The dimensions of the image in the .PCX file need not
  1676.                match the screen dimensions exactly; any 16-color image
  1677.                may be loaded to a 16-color screen (up to 800 x 600); if
  1678.                the image is too large for the video buffer, either the
  1679.                upper left portion of the image is unpacked, or you may
  1680.                re-size the video buffer (see BufferDim) to fit the image.
  1681.                Any 2-color ("monochrome") image may be loaded to any
  1682.                monochrome screen.
  1683.  
  1684.                256-color PCX files intended for the standard 320x200
  1685.                mode 13h may be loaded to the non-standard VGA13X modes.
  1686.                In VGA13X modes with 400 or 480 vertical pixel rows,
  1687.                a 320x200 image is stretched to fit image proportions.
  1688. Returns:       if CF = 0, no error
  1689.                if CF = 1, AX = DOS error code
  1690. Uses:          AX, flags
  1691. Supports:      All ASMLIB graphics modes EXCEPT:
  1692.                   InColor (palette not working right)
  1693.                   mode 04h, 05h (no palette)
  1694.                   mode 0Fh (EGA monochrome)
  1695. Example:       see PCXInfo and BufferDim         
  1696.                
  1697.  
  1698.  
  1699. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1700.  
  1701. PUTBITBLOCK:   restores bit block saved by GetBitBlock
  1702. PUTBITPLANE:   restores bit plane saved by GetBitPlane
  1703. Source:        same as GetBitBlock or GetBitPlane
  1704.  
  1705. Call with:     DS:[BX] pointing to upper left corner coordinates
  1706.                ES:[DI] pointing to buffer with stored bit block
  1707.                 PutBitPlane: AL = plane number
  1708.                 valid plane numbers for 16-color modes are 0 - 3
  1709.                                     for EGA mode 11h       0 & 2
  1710.  
  1711.                Drawmodes supported are:
  1712.                 mode 13h, VGA13x, SVGA256:
  1713.                  1 = replace existing screen area with bit block
  1714.                  2 = replace existing screen with non-zero pixels
  1715.                      in bit block
  1716.  
  1717.                 HGraph (InColor):
  1718.                  4 = AND the bit block with the existing screen
  1719.                  3 = OR the bit block with the existing screen
  1720.                  1,2 = replace existing screen area with bit block
  1721.                  0 = XOR the bit block with the existing image
  1722.                 -1,-2 = replace existing screen area with inverse bit block
  1723.  
  1724.                 16-color EGA/VGA-type modes and mode 0Fh:
  1725.                  same as InColor, plus:
  1726.                 -3 = OR the inverse bit block with the existing screen
  1727.                 -4 = AND the inverse bit block with the existing screen
  1728.  
  1729.                 mode 04h, 05h, 06h, 40h, HGraph (mono), 11h:
  1730.                  4, 1, 0, -1 same as InColor
  1731.                  2, 3 = combine non-zero pixels in the bit block with the
  1732.                         pre-existing image
  1733.                 -2 = combine non-zero pixel in the inverse bit block with
  1734.                      the pre-existing screen image
  1735.  
  1736.                Most PutBitBlock code ignores View limits (see GetView)
  1737.                but BB08.ASM, BB10.ASM and BB14.ASM (for 256-color modes)
  1738.                will clip bitblocks at View boundaries.
  1739.  
  1740. Returns:       nothing
  1741. Uses:          nothing
  1742. Supports:      all ASMLIB graphics modes
  1743. Example:       see GetBitBlock
  1744.  
  1745.  
  1746. bit block formats explained on following pages
  1747.  
  1748.  
  1749. ; BIT BLOCK FORMATS
  1750.  
  1751. ; mode 04h, 05h, 06h Hercules monochrome, 11h, and bit planes
  1752. ;
  1753. ; the first word in the buffer is the number of pixel rows (vertical)
  1754. ; in the bit block; the second word is the number of bytes per screen row;
  1755. ; the fifth byte is a bit mask for the last byte of each pixel row.
  1756. ; The bit mask = 0FFh for byte-aligned bit blocks.
  1757.  
  1758. bblock  dw 15,5              ; 15 rows, 5 bytes per row
  1759.         db 11111110b         ; bit mask for right end of pixel row
  1760.                              ; bit block data follows:
  1761.                              ;  15 rows, 5 bytes per row
  1762.         db 00000000b,10000000b,00000000b,10000000b,00000010b
  1763.         db 00000001b,11000000b,00000001b,11000000b,00000110b
  1764.         db 00000011b,11100000b,00000011b,11100000b,00001100b
  1765.         db 00000111b,01110000b,00000111b,01110000b,00011000b
  1766.         db 00001110b,00111000b,00001110b,00111000b,00110000b
  1767.         db 00011100b,00011100b,00011100b,00011100b,01100000b
  1768.         db 00000001b,11000000b,00000001b,11000000b,11000000b
  1769.         db 00000001b,11000000b,00000001b,11000000b,01100000b
  1770.         db 00000001b,11000000b,00000001b,11000000b,00110000b
  1771.         db 00000001b,11000000b,00000001b,11000000b,00011000b
  1772.         db 00000001b,11000000b,00000001b,11000000b,00001100b
  1773.         db 00000001b,11000000b,00000001b,11000000b,00000110b
  1774.         db 00000001b,11000000b,00000001b,11000000b,00000010b
  1775.         db 00000001b,11000000b,00000001b,11000000b,00000000b
  1776.         db 00000001b,11000000b,00000001b,11000000b,00000000b
  1777.  
  1778. ; 16-color modes: 0Dh, 0Eh, 10h, 12h, 6Ah, xmode16, InColor:
  1779. ; same as above, except there are 4 planes of bit block data
  1780. ; i. e., 4 groups of 15-row, 5-byte data; plane 3 is the first
  1781. ; block, followed by planes 2, 1, and 0.
  1782.  
  1783. ; EGA monochrome mode: 0Fh
  1784. ; similar to 16-color modes, but there are only 2 groups of bit
  1785. ; block data instead of 4
  1786.  
  1787.  
  1788. ; 256-color modes on next page
  1789.  
  1790.  
  1791. ; BIT BLOCK FORMATS
  1792.  
  1793. ; all 256-color modes: no bit mask in the bit block header
  1794.  
  1795. red     equ 12                    ; bright red
  1796. blue    equ 1                     ; blue
  1797.  
  1798. bblock  dw 12,5                   ; 12 rows, 5 bytes per row
  1799.         db red, red, blue,red, red
  1800.         db red, blue,red, blue,red
  1801.         db blue,red, red, red, blue
  1802.         db red, red, blue,red, red
  1803.         db red, blue,red, blue,red
  1804.         db blue,red, red, red, blue
  1805.         db red, red, blue,red, red
  1806.         db red, blue,red, blue,red
  1807.         db blue,red, red, red, blue
  1808.         db red, red, blue,red, red
  1809.         db red, blue,red, blue,red
  1810.         db blue,red, red, red, blue
  1811.  
  1812.  
  1813. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1814.  
  1815. PUTDOT:        change a pixel on a graphics screen
  1816. Source:        putdot.asm ($graph.asm, $putdot.asm, others)
  1817.  
  1818. Call with:     DS:[BX] pointing to x & y coordinates
  1819.                Drawmodes supported are:
  1820.                (monochrome)
  1821.                 1 = set pixel
  1822.                 0 = toggle pixel
  1823.                -1 = erase pixel
  1824.  
  1825.                (color modes)
  1826.                 3 = OR foreground color with pre-existing pixel
  1827.                 1, 2 = replace pixel with foreground color
  1828.                 0 = XOR foreground color with pre-existing pixel
  1829.                -1, -2 = replace pixel with background color
  1830.                -3 = OR background color with pre-existing pixel
  1831. Returns:       if CF = 0, no error
  1832.                if CF = 1, pixel coordinates outside active view area
  1833. Uses:          CF; all other registers and flags are saved
  1834. Supports:      all ASMLIB graphics modes
  1835. Example:
  1836.  
  1837. include asm.inc
  1838.  
  1839. extrn   putdot:proc
  1840.  
  1841. .data
  1842. extrn   drawmode:byte
  1843. x       dw 100,117            ; pixel at x = 100, y = 117
  1844.  
  1845. .code
  1846. ; program fragment assumes DS:@data
  1847.         .
  1848.         .
  1849.         .
  1850.         mov   drawmode,1      ; use foreground color
  1851.         lea   bx,x            ; point to pixel coordinates
  1852.         call  putdot
  1853.  
  1854.  
  1855.  
  1856. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1857.  
  1858. PCXINFO:       read vital information from .PCX-format graphics file
  1859. Source:        pcxinfo.asm
  1860.  
  1861. Call with:     DS:[DX] pointing to ASCIIZ name of .PCX file
  1862. Returns:       DS:[BX] pointing to PCX information data structure:
  1863.  
  1864.                pcx_info struc
  1865.                horiz    dw 0
  1866.                vert     dw 0
  1867.                colors   dw 0
  1868.                planes   db 0
  1869.                xpixels  dw 0
  1870.                ypixels  dw 0
  1871.                pcx_info ends
  1872.  
  1873.                horiz and vert are screen dimensions
  1874.                colors: 16 for EGA/VGA 16-color modes, 256 for 256-color modes
  1875.                planes: number of pit planes encoded
  1876.                        4 for 16-color modes, 1 for monochrome, CGA or mode 13h
  1877.                xpixels: horizontal image size
  1878.                ypixels: vertical image size
  1879.  
  1880.  
  1881.  
  1882. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1883.  
  1884. RESETVIEW:     restores default view area on active graphics page and
  1885.                returns a pointer to the view data
  1886. Source:        view.asm ($graph.asm)
  1887.  
  1888. Call with:     no parameters
  1889.                ResetView restores the default full screen view area.
  1890.                The far pointer returned points to ASMLIB's data area in
  1891.                $graph.obj for the active graphics page's view coordinates.
  1892. Returns:       ES:[BX] pointing to the active page's view data.
  1893. Uses:          ES, BX; all other registers and flags are saved
  1894. Supports:      all ASMLIB graphics modes
  1895. Example:
  1896.  
  1897. include asm.inc
  1898.  
  1899. extrn   resetview:proc
  1900.  
  1901. x0 EQU word ptr ES:[BX]
  1902. y0 EQU word ptr ES:2[BX]
  1903. x1 EQU word ptr ES:4[BX]
  1904. y1 EQU word ptr ES:6[BX]
  1905.  
  1906. .code
  1907.         .
  1908.         .
  1909.         .
  1910.         call  resetview
  1911.  
  1912.  
  1913.  
  1914. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1915.  
  1916. SCREENORIGIN:  control position of re-sized video buffer on screen
  1917.                see also BufferDim
  1918. Source:        scrnorig.asm
  1919.  
  1920. Call with:     DS:[BX] pointing to upper-left coordinates of logical
  1921.                video buffer to be displayed at upper-left corner of screen.
  1922. Returns:       nothing
  1923. Uses:          nothing
  1924. Supports:      EGA/VGA 16-color modes
  1925.                VGA13x 256-color modes
  1926. Example:       see BufferDim
  1927.  
  1928.  
  1929. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1930.  
  1931. SHOWGPAGE:     change graphics page displayed on screen
  1932.                See also UseGPage and GPage.
  1933. Source:        gpage1.asm ($graph.asm, $herc.asm)
  1934.  
  1935. Call with:     BL = page number
  1936. Returns:       Carry Flag = error code
  1937.                if CF = 0, no error
  1938.                if CF = 1, bad page number
  1939. Uses:          CF
  1940. Supports:      HGraph (mono and InColor), modes 0Dh, 0Eh, 0Fh, 10h, VGA13X
  1941. Example:
  1942.  
  1943. include asm.inc
  1944.  
  1945. extrn   showgpage:proc
  1946.  
  1947. .code
  1948.         .
  1949.         .
  1950.         .
  1951.         mov   bl,1           ; show page 1
  1952.         call  showgpage
  1953.         jc    no_page_1      ; no page 1 for this mode
  1954.  
  1955. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1956.  
  1957. SHOWGPLANE:    show one or more planes of multi-plane EGA/VGA screen
  1958. Source:        gplane.asm ($graph.asm)
  1959.  
  1960. Call with:     AL = plane mask
  1961.                Bits set in the plane mask correspond to the plane displayed.
  1962.                ASMLIB's default mask is 00001111b, enabling all 4 planes.
  1963. Returns:       CF = error flag
  1964.                if CF = 0, no error
  1965.                if CF = 1, bad plane mask or graphics mode
  1966. Uses:          CF
  1967. Supports:      EGA & VGA 16-color modes, including VESA 6Ah, xmode16
  1968.                    and SVGA16
  1969.                EGA monochrome: planes 0 and 2
  1970.                    (mask = 00000101b for both planes)
  1971.                Hercules InColor
  1972. Example:
  1973.  
  1974. include asm.inc
  1975.  
  1976. extrn   showgplane:proc
  1977.  
  1978. .code
  1979.         .
  1980.         .
  1981.         .
  1982.         mov   al,00000101b      ; show planes 0 and 2
  1983.         call  showgplane
  1984.         jc    error             ; error control
  1985.  
  1986.  
  1987.  
  1988. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1989.  
  1990. SMALLTEXT:     change GPrint, GPrintX and GPrint2X default to 8x8 characters
  1991.                in Hercules and modes 10h, 11h, 12h; makes 8x8-size
  1992.                high ASCII characters available to GPrint in all modes
  1993. Source:        smalltxt.asm (f8x8.asm, $graph.asm)
  1994.  
  1995. STDTEXT:       restore GPrint default characters (see GPrint)
  1996. Source:        stdtext.asm (f8x14.asm, fontdata.asm)
  1997.  
  1998. Call with:     no parameters
  1999. Returns:       nothing
  2000. Uses:          nothing; all registers and flags are saved
  2001. Example:
  2002.  
  2003. include asm.inc
  2004.  
  2005. extrn   smalltext:proc, stdtext:proc
  2006.  
  2007. .code
  2008.         .
  2009.         .
  2010.         .
  2011. ; make GPrint use the small 8x8 characters
  2012. ; make sure high ASCII characters are available
  2013.         call   smalltext
  2014.         .
  2015.         .
  2016.  
  2017. ; sometime later, I want to use larger 8x14 characters
  2018.         call   stdtext
  2019.  
  2020.  
  2021. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2022.  
  2023. UC2SYS:        convert user-defined coordinates to system coordinates
  2024. Source:        uc2sys.asm ($graph.asm)
  2025.  
  2026. Call with:     DS:[BX] pointing to (x0,y0,x1,y1) coordinates in
  2027.                user-defined format
  2028.                assumes DS:@data
  2029. Returns:       DS:[BX] pointing to (x0,y0,x1,y1) coordinates in system
  2030.                format
  2031.                UCINIT and UC2SYS allow the programmer to define a
  2032.                graph coordinate system to fit the data, and converts
  2033.                the system's y-orientation from top-to-bottom to the more
  2034.                familiar bottom-to-top
  2035.                US2SYS maintains a separate data area for converted
  2036.                coordinates; the input coordinates are not changed
  2037. Uses:          BX
  2038. Supports:      all ASMLIB graphics modes; user-defined coordinates
  2039.                from -32767 to +32767; see also UCINIT
  2040. Example:       see UCINIT
  2041.  
  2042.  
  2043. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2044.  
  2045. UCINIT:        specify user-defined coordinates
  2046. Source:        uc2sys.asm ($graph.asm)
  2047.  
  2048. Call with:     DS:[BX] pointing to desired xmin, ymin, xmax, ymax
  2049.                coordinates (xmax-xmin < 32767, ymax-ymin < 32767)
  2050.                assumes DS:@data
  2051.                ASMLIB's default user coordinates are (0,0,1000,1000)
  2052. Returns:       nothing
  2053. Uses:          nothing
  2054. Example:
  2055.  
  2056. ; I'm plotting a graph on the screen with x-axis data from 1983 to 2007
  2057. ; and y-axis data from -72 to 140
  2058. ; I'll leave some space on each side for titles, etc.
  2059.  
  2060. extrn   ucinit:proc, uc2sys:proc
  2061. extrn   drawbox:proc
  2062.  
  2063. .data
  2064. x0      dw 1975    ; xmin
  2065. y0      dw -80     ; ymin
  2066. x1      dw 2014    ; xmax
  2067. y1      dw 148     ; ymax
  2068.  
  2069. .code
  2070. ; program fragment assumes DS:@data
  2071.         .
  2072.         .
  2073.         .
  2074. ; establish coordinates
  2075.         lea     bx,x0
  2076.         call    ucinit
  2077.  
  2078. ; draw a box arouund the graph
  2079.         mov     x0,1983
  2080.         mov     y0,-72
  2081.         mov     x1,2007
  2082.         mov     y1,140
  2083.         lea     bx,x0
  2084.         call    uc2sys
  2085.         call    drawbox
  2086.  
  2087. ; SEE ALSO BARGRAPH.ASM EXAMPLE PROGRAM
  2088.  
  2089.  
  2090. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2091.  
  2092. USEGPAGE:      changes active graphics page used by ASMLIB
  2093.                does not change page displayed (see GPage and ShowGPage)
  2094. Source:        gpage.asm ($graph.asm, $herc.asm)
  2095.  
  2096. Call with:     BL = page number
  2097. Returns:       if CF = 0, no error
  2098.                if CF = 1, bad page number
  2099. Uses:          CF
  2100. Supports:      HGraph (mono and InColor) with Use64k
  2101.                EGA and VGA: modes with more than one page
  2102. Example:
  2103.  
  2104. include asm.inc
  2105.  
  2106. extrn   usegpage:proc
  2107.  
  2108. .code
  2109.         .
  2110.         .
  2111.         mov   bl,1
  2112.         call  usegpage
  2113.         jc    oops
  2114.  
  2115.  
  2116.  
  2117. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2118.  
  2119. VIEWLIMIT:     determine current mode's maximum dimensions
  2120. Source:        view.asm ($graph.asm)
  2121.  
  2122. Call with:     no parameters
  2123. Returns:       ES:[BX] pointing to xmax
  2124.                ES:2[BX] pointing to ymax
  2125. Uses:          ES, BX
  2126. Supports:      all ASMLIB graphics modes
  2127. Example:
  2128.  
  2129. include asm.inc
  2130.  
  2131. extrn   viewlimit:proc
  2132.  
  2133. .code
  2134.         .
  2135.         .
  2136.         call  viewlimit
  2137.  
  2138.